package c.a.a.z.c;

import android.graphics.Matrix;
import android.graphics.PointF;
import c.a.a.b0.j.b;
import c.a.a.b0.j.e;
import c.a.a.b0.j.g;
import c.a.a.b0.j.l;
import c.a.a.b0.j.m;
import c.a.a.f0.a;
import c.a.a.f0.c;
import c.a.a.f0.d;
import c.a.a.q;
import java.util.Collections;

/* compiled from: TransformKeyframeAnimation */
public class o {
    public final Matrix a = new Matrix();
    public final Matrix b;
    public final Matrix c;
    public final Matrix d;
    public final float[] e;
    public a<PointF, PointF> f;
    public a<?, PointF> g;
    public a<d, d> h;
    public a<Float, Float> i;
    public a<Integer, Integer> j;
    public c k;
    public c l;
    public a<?, Float> m;
    public a<?, Float> n;

    public o(l lVar) {
        a aVar;
        c cVar;
        e eVar = lVar.a;
        if (eVar == null) {
            aVar = null;
        } else {
            aVar = eVar.a();
        }
        this.f = aVar;
        m mVar = lVar.b;
        if (mVar == null) {
            aVar = null;
        } else {
            aVar = mVar.a();
        }
        this.g = aVar;
        g gVar = lVar.c;
        if (gVar == null) {
            aVar = null;
        } else {
            aVar = gVar.a();
        }
        this.h = aVar;
        b bVar = lVar.d;
        if (bVar == null) {
            aVar = null;
        } else {
            aVar = bVar.a();
        }
        this.i = aVar;
        bVar = lVar.f;
        if (bVar == null) {
            cVar = null;
        } else {
            cVar = (c) bVar.a();
        }
        this.k = cVar;
        if (cVar != null) {
            this.b = new Matrix();
            this.c = new Matrix();
            this.d = new Matrix();
            this.e = new float[9];
        } else {
            this.b = null;
            this.c = null;
            this.d = null;
            this.e = null;
        }
        bVar = lVar.g;
        if (bVar == null) {
            cVar = null;
        } else {
            cVar = (c) bVar.a();
        }
        this.l = cVar;
        c.a.a.b0.j.d dVar = lVar.e;
        if (dVar != null) {
            this.j = dVar.a();
        }
        bVar = lVar.h;
        if (bVar != null) {
            this.m = bVar.a();
        } else {
            this.m = null;
        }
        b bVar2 = lVar.i;
        if (bVar2 != null) {
            this.n = bVar2.a();
        } else {
            this.n = null;
        }
    }

    public void a(c.a.a.b0.l.b bVar) {
        bVar.e(this.j);
        bVar.e(this.m);
        bVar.e(this.n);
        bVar.e(this.f);
        bVar.e(this.g);
        bVar.e(this.h);
        bVar.e(this.i);
        bVar.e(this.k);
        bVar.e(this.l);
    }

    public void b(a.b bVar) {
        a aVar = this.j;
        if (aVar != null) {
            aVar.a.add(bVar);
        }
        aVar = this.m;
        if (aVar != null) {
            aVar.a.add(bVar);
        }
        aVar = this.n;
        if (aVar != null) {
            aVar.a.add(bVar);
        }
        aVar = this.f;
        if (aVar != null) {
            aVar.a.add(bVar);
        }
        aVar = this.g;
        if (aVar != null) {
            aVar.a.add(bVar);
        }
        aVar = this.h;
        if (aVar != null) {
            aVar.a.add(bVar);
        }
        aVar = this.i;
        if (aVar != null) {
            aVar.a.add(bVar);
        }
        c cVar = this.k;
        if (cVar != null) {
            cVar.a.add(bVar);
        }
        cVar = this.l;
        if (cVar != null) {
            cVar.a.add(bVar);
        }
    }

    public <T> boolean c(T t, c<T> cVar) {
        a aVar;
        c cVar2;
        if (t == q.e) {
            aVar = this.f;
            if (aVar == null) {
                this.f = new p(cVar, new PointF());
            } else {
                cVar2 = aVar.e;
                aVar.e = cVar;
            }
        } else if (t == q.f) {
            aVar = this.g;
            if (aVar == null) {
                this.g = new p(cVar, new PointF());
            } else {
                cVar2 = aVar.e;
                aVar.e = cVar;
            }
        } else if (t == q.k) {
            aVar = this.h;
            if (aVar == null) {
                this.h = new p(cVar, new d());
            } else {
                cVar2 = aVar.e;
                aVar.e = cVar;
            }
        } else if (t == q.l) {
            aVar = this.i;
            if (aVar == null) {
                this.i = new p(cVar, Float.valueOf(0.0f));
            } else {
                cVar2 = aVar.e;
                aVar.e = cVar;
            }
        } else if (t == q.c) {
            aVar = this.j;
            if (aVar == null) {
                this.j = new p(cVar, Integer.valueOf(100));
            } else {
                cVar2 = aVar.e;
                aVar.e = cVar;
            }
        } else {
            a aVar2;
            c cVar3;
            c cVar4;
            if (t == q.y) {
                aVar2 = this.m;
                if (aVar2 != null) {
                    if (aVar2 == null) {
                        this.m = new p(cVar, Integer.valueOf(100));
                    } else {
                        cVar3 = aVar2.e;
                        aVar2.e = cVar;
                    }
                }
            }
            if (t == q.z) {
                aVar2 = this.n;
                if (aVar2 != null) {
                    if (aVar2 == null) {
                        this.n = new p(cVar, Integer.valueOf(100));
                    } else {
                        cVar3 = aVar2.e;
                        aVar2.e = cVar;
                    }
                }
            }
            if (t == q.m) {
                c cVar5 = this.k;
                if (cVar5 != null) {
                    if (cVar5 == null) {
                        this.k = new c(Collections.singletonList(new a(Float.valueOf(0.0f))));
                    }
                    cVar4 = this.k;
                    cVar2 = cVar4.e;
                    cVar4.e = cVar;
                }
            }
            if (t == q.n) {
                cVar4 = this.l;
                if (cVar4 != null) {
                    if (cVar4 == null) {
                        this.l = new c(Collections.singletonList(new a(Float.valueOf(0.0f))));
                    }
                    cVar4 = this.l;
                    cVar2 = cVar4.e;
                    cVar4.e = cVar;
                }
            }
            return false;
        }
        return true;
    }

    public final void d() {
        for (int i = 0; i < 9; i++) {
            this.e[i] = 0.0f;
        }
    }

    public Matrix e() {
        PointF pointF;
        float f;
        float floatValue;
        float sin;
        this.a.reset();
        a aVar = this.g;
        if (aVar != null) {
            pointF = (PointF) aVar.e();
            f = pointF.x;
            if (!(f == 0.0f && pointF.y == 0.0f)) {
                this.a.preTranslate(f, pointF.y);
            }
        }
        aVar = this.i;
        if (aVar != null) {
            if (aVar instanceof p) {
                floatValue = ((Float) aVar.e()).floatValue();
            } else {
                floatValue = ((c) aVar).j();
            }
            if (floatValue != 0.0f) {
                this.a.preRotate(floatValue);
            }
        }
        if (this.k != null) {
            c cVar = this.l;
            floatValue = cVar == null ? 0.0f : (float) Math.cos(Math.toRadians((double) ((-cVar.j()) + 90.0f)));
            c cVar2 = this.l;
            sin = cVar2 == null ? 1.0f : (float) Math.sin(Math.toRadians((double) ((-cVar2.j()) + 90.0f)));
            float tan = (float) Math.tan(Math.toRadians((double) this.k.j()));
            d();
            float[] fArr = this.e;
            fArr[0] = floatValue;
            fArr[1] = sin;
            float f2 = -sin;
            fArr[3] = f2;
            fArr[4] = floatValue;
            fArr[8] = 1.0f;
            this.b.setValues(fArr);
            d();
            fArr = this.e;
            fArr[0] = 1.0f;
            fArr[3] = tan;
            fArr[4] = 1.0f;
            fArr[8] = 1.0f;
            this.c.setValues(fArr);
            d();
            float[] fArr2 = this.e;
            fArr2[0] = floatValue;
            fArr2[1] = f2;
            fArr2[3] = sin;
            fArr2[4] = floatValue;
            fArr2[8] = 1.0f;
            this.d.setValues(fArr2);
            this.c.preConcat(this.b);
            this.d.preConcat(this.c);
            this.a.preConcat(this.d);
        }
        aVar = this.h;
        if (aVar != null) {
            d dVar = (d) aVar.e();
            sin = dVar.a;
            if (!(sin == 1.0f && dVar.b == 1.0f)) {
                this.a.preScale(sin, dVar.b);
            }
        }
        aVar = this.f;
        if (aVar != null) {
            pointF = (PointF) aVar.e();
            f = pointF.x;
            if (!(f == 0.0f && pointF.y == 0.0f)) {
                this.a.preTranslate(-f, -pointF.y);
            }
        }
        return this.a;
    }

    public Matrix f(float f) {
        a aVar = this.g;
        PointF pointF = null;
        PointF pointF2 = aVar == null ? null : (PointF) aVar.e();
        a aVar2 = this.h;
        d dVar = aVar2 == null ? null : (d) aVar2.e();
        this.a.reset();
        if (pointF2 != null) {
            this.a.preTranslate(pointF2.x * f, pointF2.y * f);
        }
        if (dVar != null) {
            double d = (double) f;
            this.a.preScale((float) Math.pow((double) dVar.a, d), (float) Math.pow((double) dVar.b, d));
        }
        aVar = this.i;
        if (aVar != null) {
            float floatValue = ((Float) aVar.e()).floatValue();
            aVar2 = this.f;
            if (aVar2 != null) {
                pointF = (PointF) aVar2.e();
            }
            Matrix matrix = this.a;
            floatValue *= f;
            f = 0.0f;
            float f2 = pointF == null ? 0.0f : pointF.x;
            if (pointF != null) {
                f = pointF.y;
            }
            matrix.preRotate(floatValue, f2, f);
        }
        return this.a;
    }
}
